
<%@ page language="java" import="java.util.*"%>
<%@ page contentType="text/html;charset=utf-8" import="java.sql.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>


		<title>My JSP 'Login.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<script type="text/javascript">
		
	        function removeValue(){
	        
	          var warning=document.getElementById("warning");
	           warning.firstChild.nodeValue="";
	        
	        }
	        
	        
	        function test(){
	             var name=document.getElementById("na");
	             var passwd=document.getElementById("ps");
	              if(name.value==""||passwd.value==""){
	                var warning=document.getElementById("warning");
	                warning.innerHTML="*账号/密码不得为空";
	                return false;
	              }
	              else{ 
	               return true;
	             }         
	        }
	        

	       
	   
	   
	   </script>

		<style>
		
        #warning {
	         color: red;
	         font-size: 10px;
	         font-weight: 10;
        }
         label{
              align:center;
              font-weight:bolder;
         }
         
        </style>

	</head>

	<body>
	

		
	    <h1>登录系统</h1>
          <hr/>		

		<div style="position:absolute;left:450px" >
			<form action="servlet/LoginServlet" onsubmit="return test()"
				method="post" onclick="removeValue()";>
		    <table>
		    <tr>
			      <td>账号：</td>
			      <td><input type="text" name="name" id="na" /></td>
			</tr>
			<tr>
                  <td>密码：</td>
                  <td><input type="password" name="passwd" id="ps" /></td>
                  <td><font id="warning" >
                  <%
                    Integer errorId;
                     String registerresult;
                     if( (errorId=(Integer)session.getAttribute("errorLogin"))!=null){
                               if(errorId==1) out.println("*密码错误"); 
                                if(errorId==2) out.println("*用户未注册");
                                session.removeAttribute("errorLogin");
                                 session.removeAttribute("errorUser");
                         }        
                    if((registerresult=(String)session.getAttribute("registerresult"))!=null){
                    
                                 out.println(registerresult);
                                  session.removeAttribute("registerresult");}
                     %>
                   </font></td>
			</tr>	
		
		
            
                <tr>
                    <td></td>  
                    <td><input type="submit" value="登录" />&nbsp &nbsp<input type="reset" value="重置" /></td> 	
			    </tr>
		        </table>
			</form>

		</div>
	
		<div align="right"><a style="font-size:15px;font-weight:200px" href="RegisterJsp.jsp">没有账号，请注册！</a></div>
	</body>
</html>
